package com.cdy.jxc_project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cdy.jxc_project.domain.TSupplier;
import com.cdy.jxc_project.domain.vo.TSupplierVo;
import com.cdy.jxc_project.mapper.TSupplierMapper;
import com.cdy.jxc_project.service.TSupplierService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/*
 * @Project:jxc_project
 * @Author:cdy(缘生)
 * @Motto:放下杂念,只为迎接明天更好的自己
 * @Date:2023/4/21 18:18
 * */
@Service
@Transactional
public class TSupplierServiceImpl extends ServiceImpl<TSupplierMapper, TSupplier>implements TSupplierService {

    @Resource
    private TSupplierMapper tSupplierMapper;
    @Override
    public Page<TSupplier> queryTSupplierPage(TSupplierVo tSupplierVo) {
        QueryWrapper<TSupplier> queryWrapper = new QueryWrapper<TSupplier>();
        queryWrapper.like("name",tSupplierVo.getName());
        queryWrapper.like("address",tSupplierVo.getAddress());

        Page<TSupplier> page = new Page(tSupplierVo.getCurrentPage(), tSupplierVo.getPageSize());
        return tSupplierMapper.selectPage(page,queryWrapper);
    }

    @Override
    public boolean deleteTSupplier(Integer id) {
        if (tSupplierMapper.deleteById(id)>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public int insertTSupplier(TSupplier tSupplier) {
        tSupplierMapper.insert(tSupplier);
        return 0;
    }

    @Override
    public int updateTSupplier(TSupplier tSupplier) {
        tSupplierMapper.updateById(tSupplier);
        return 0;
    }
}
